package com.basin.common.satoken.support;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.convert.Convert;
import com.basin.common.redisson.util.RedisUtil;
import org.redisson.api.RedissonClient;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
public final class BasinAuthTool {
    private static final String TENANT_KEY = "tenant_id";
    private static final RedissonClient REDIS_CLIENT = RedisUtil.getClient();

    public static String getTenantId() {
        Object tenantId = StpUtil.getExtra(TENANT_KEY);
        return Convert.toStr(tenantId);
    }

    public static String getLoginId() {
        Object loginId = StpUtil.getLoginId();
        return Convert.toStr(loginId);
    }

    public static void removeCache(String... redisKeys) {
        REDIS_CLIENT.getKeys().delete(redisKeys);
    }
}
